package com.upf1sh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.upf1sh.bean.GreenRover030001;
import com.upf1sh.mapper.GreenRover030001Mapper;
import com.upf1sh.service.GreenRover030001Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【green_rover_030001(消毒机器人)】的数据库操作Service实现
* @createDate 2024-09-19 20:56:41
*/
@Service
public class GreenRover030001ServiceImpl extends ServiceImpl<GreenRover030001Mapper, GreenRover030001> implements GreenRover030001Service {

    @Autowired
    private GreenRover030001Mapper greenRoverMapper;

    @Override
    public List<GreenRover030001> getList(GreenRover030001 greenRover030001) {
        QueryWrapper<GreenRover030001> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(greenRover030001.getDeviceName()!=null,"device_name",  greenRover030001.getDeviceName());
        queryWrapper.eq(greenRover030001.getDeviceId()!=null,"device_id", greenRover030001.getDeviceId());
        queryWrapper.eq(greenRover030001.getProductId()!=null,"product_id",greenRover030001.getProductId());
        List<GreenRover030001> greenRover030001s = greenRoverMapper.selectList(queryWrapper);
        return greenRover030001s;
    }

    @Override
    public int add(GreenRover030001 greenRover030001) {
        return  greenRoverMapper.insert(greenRover030001);
    }

    @Override
    public int delete(GreenRover030001 greenRover030001) {
        return greenRoverMapper.deleteById(greenRover030001.getId());
    }

    @Override
    public int update(GreenRover030001 greenRover030001) {
        return greenRoverMapper.updateById(greenRover030001);
    }

    @Override
    public GreenRover030001 getGreenRover030001(int id) {
        return greenRoverMapper.selectById(id);
    }

    @Override
    public GreenRover030001 getInfo(GreenRover030001 greenRover030001) {
        QueryWrapper<GreenRover030001> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("device_name", greenRover030001.getDeviceName());
        queryWrapper.eq("product_id",greenRover030001.getProductId());
       return greenRoverMapper.selectOne(queryWrapper);
    }
}




